class ShoppingCar{
    constructor(){
        //this.data = data;
        this.ul = document.querySelector("main .center ul");
        this.url = "http://localhost/ylf/json/list.json"
        //console.log(this.ul)
        this.init();
    }
    init(){
        ajax({
            url:this.url,
        }).then((data)=>{
            this.data = JSON.parse(data);
            this.display();
        })
    }
    display(){
        //console.log(this.data)
        let str = "";
        for(let i=0;i<this.data.length; i++){
            str += `<li index = "${this.data[i].goodsId}">
                        <a href="./page/Detail.html?id=${this.data[i].goodsId}">
                        <img src="${this.data[i].img.largeImg[0]}">
                        <span>￥${this.data[i].span}</span>
                        <s>${this.data[i].s}</s>
                        <p>${this.data[i].p}<em>${this.data[i].em}</em></p>
                        </a>
                    </li>`
        }
        this.ul.innerHTML = str;

       
    }
}
new ShoppingCar();

class Nav{
    constructor(){
        //this.data = data;
        this.ul = document.querySelector("#brand #day .center ul");
        this.oul = document.querySelector("#brand #day .bottom ul");
        this.url = "http://localhost/ylf/json/data.json";
       
        //console.log(this.ul)
        this.init();
    }
    init(){
        ajax({
            url:this.url,
        }).then((data)=>{
            this.data = JSON.parse(data);
            this.display();
        })
    }
    display(){
       // console.log(this.data)
        let str = "";
        for(let i=0;i<this.data.length; i++){
            str += ` <li><a href="${this.data[i].a}"><img src="${this.data[i].img}" alt=""><font>${this.data[i].font}</font><span>进入活动</span></a></li>`
        }
        this.ul.innerHTML = str;
        let newstr = "" ;
        for(let i=0;i<this.data.length; i++){
            newstr += ` <li><a href=""><img src="${this.data[i].small}" alt=""></a></li>`
        }
        this.oul.innerHTML = newstr;
       
    }
}
new Nav();

class New{
    constructor(){
        //this.data = data;
        this.oul = document.querySelector("#brand #day .bottom ul");
        this.url = "http://localhost/ylf/json/new.json";
     
        //console.log(this.ul)
        this.init();
    }
    init(){
        ajax({
            url:this.url,
        }).then((data)=>{
            this.data = JSON.parse(data);
            this.display();
        })
    }
    display(){
        let newstr = "" ;
        for(let i=0;i<this.data.length; i++){
            newstr += ` <li><a href=""><img src="${this.data[i].small}" alt=""></a></li>`
        }
        this.oul.innerHTML = newstr;

        
    }
}
new New();